package com.yl.common.util

import android.app.Application
import android.widget.Toast

/**
 * Created by stew on 7/27/22.
 */
object ToastUtil {
    lateinit var mContext: Application
    var mToast: Toast? = null

    fun init(context: Application) {
        mContext = context
    }

    fun showMsg(message: String) {
        if (mToast == null) {
            mToast = Toast.makeText(mContext, message, Toast.LENGTH_SHORT)
        } else {
            mToast!!.cancel()
            mToast = Toast.makeText(mContext, message, Toast.LENGTH_SHORT)
            mToast!!.setDuration(Toast.LENGTH_SHORT)
        }
        mToast!!.show()
    }
}